package com.wms.service.impl;

import com.wms.entity.ResourceAuthority;
import com.wms.mapper.ResourceAuthorityMapper;
import com.wms.service.ResourceAuthorityService;
import io.jsonwebtoken.lang.Assert;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ResourceAuthorityServiceImpl extends BaseServiceImpl<ResourceAuthorityMapper, ResourceAuthority> implements ResourceAuthorityService {


    @Resource
    private ResourceAuthorityMapper resourceAuthorityMapper;

    @Override
    public void delete(ResourceAuthority resourceAuthority) {
        resourceAuthorityMapper.deleteEntity(resourceAuthority);
    }

    @Override
    public Boolean exist(ResourceAuthority resourceAuthority) {
        Assert.notNull(resourceAuthority);
        return resourceAuthorityMapper.exist(resourceAuthority);
    }

    @Override
    public void deleteByAuthorityId(Long authorityId) {
        Assert.notNull(authorityId);
        resourceAuthorityMapper.deleteByAuthorityId(authorityId);
    }

    @Override
    public void deleteByAuthorityIds(List<Long> authorityIds) {
        Assert.notEmpty(authorityIds);
        resourceAuthorityMapper.deleteByAuthorityIds(authorityIds);
    }

    @Override
    public List<Long> findAuthorityIdByResourceId(Long resourceId) {
        Assert.notNull(resourceId);
        return resourceAuthorityMapper.findAuthorityIdByResourceId(resourceId);
    }
}
